package com.origin.src.import0.selector;

import com.origin.src.ApplicationTool;
import org.springframework.context.annotation.ImportAware;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

import java.util.Arrays;

public class XImportSelector implements ImportSelector {

    public XImportSelector() {
        ApplicationTool.printClass(this);
    }

    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        return new String[]{XImportSelectorBean1.class.getName(), XImportSelectorBean2.class.getName()};
    }

    public static class XImportSelectorBean1 implements ImportAware {
        public XImportSelectorBean1() {
            ApplicationTool.printClass(this);
        }

        @Override
        public void setImportMetadata(AnnotationMetadata importMetadata) {
            System.out.println("ImportAware这个注入了AnnotationMetadata:" + Arrays.toString(importMetadata.getAnnotationTypes().toArray()));
        }
    }

    public static class XImportSelectorBean2 {
        public XImportSelectorBean2() {
            ApplicationTool.printClass(this);
        }
    }



}
